import java.util.Scanner;

public class two {
    public static void main(String[] args) {
        int y = 0, m = 0, d = 0;
        int[] month = new int[]{0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
        Scanner scanner = new Scanner(System.in);
        y = scanner.nextInt();
        m = scanner.nextInt();
        d = scanner.nextInt();
        int ans = 0;
        for (int i = 1;i < m;i ++ ) {
            ans += month[i];
        }
        if (y % 4 == 0 && y % 100 != 0 || y % 400 == 0) ans += 1;
        ans += d;
        System.out.println(ans);
    }
}
